<?php

namespace app\admin\controller;

use think\Db;
use think\Request;


class Centent extends Admin
{
    // 查询数据
    public function index(Request $request)
    {
        $res = $request->get();
        if (!empty($res['title'])) {
            $data = $res['title'];
            $where['name'] = ['like', '%'.$data.'%'];
            $count = Db::table('dt_user')->where($where)->paginate(4)->count();
            if ($count == 0) {
                 $this->success('未找到查询的内容');
            }
        }else{
            $where = "";
        }

        $data = Db::table('dt_user')->field(true)->where($where)->paginate(4);
        // //查询首分类
        // //获取分页显示

        $page = $data->render();
        $this->assign('page', $page);
        $this->assign('data', $data);

        return $this->fetch('centent/centent');

    }    


    // 查询数据
    public function disbale(Request $request)
    {
        $res = $request->get();
        if (!empty($res['title'])) {
            $data = $res['title'];
            $where['name'] = ['like', '%'.$data.'%'];
            $count = Db::table('dt_user')->where($where)->paginate(4)->count();
            if ($count == 0) {
                 $this->success('未找到查询的内容');
            }
        }else{
            $where = "";
        }

        $data = Db::table('dt_user')->field(true)->where($where)->paginate(4);
        // //查询首分类
        // //获取分页显示

        $page = $data->render();
        $this->assign('page', $page);
        $this->assign('data', $data);

        return $this->fetch('centent/disable');

    }


    

 

    // 查询数据
    public function find($id)
    {



        $data = Db::table(['dt_user'=>'u','picture' => 'p'])
                    ->where('p.user_id = u.id && u.id = '.$id)
                    ->select();
        // var_dump($data);

        return view('admin@centent/detail',['data'=>$data]);
    }


    public function role($id)
    {
        $id = input('id');
        
         Db::table('picture')->where('id ='.$id) ->delete();

        return view('admin@centent/index');
    }


   

}


